namespace EntityFrameworkModel
{
    using System;
    using System.Data.Entity;
    using System.ComponentModel.DataAnnotations.Schema;
    using System.Linq;

    public partial class Model1 : DbContext
    {
        public Model1()
            : base("name=Model1")
        {
        }

        public virtual DbSet<hkb_Organization> hkb_Organization { get; set; }
        public virtual DbSet<hkb_OrganizationDayStatistics> hkb_OrganizationDayStatistics { get; set; }
        public virtual DbSet<hkb_OrganizationQualification> hkb_OrganizationQualification { get; set; }
        public virtual DbSet<hkb_OrganizationUser> hkb_OrganizationUser { get; set; }
        public virtual DbSet<hkb_RequirementBook> hkb_RequirementBook { get; set; }
        public virtual DbSet<hkb_RequirementBookCar> hkb_RequirementBookCar { get; set; }
        public virtual DbSet<hkb_RequirementBookCompany> hkb_RequirementBookCompany { get; set; }
        public virtual DbSet<hkb_RequirementBookCredit> hkb_RequirementBookCredit { get; set; }
        public virtual DbSet<hkb_RequirementBookDemand> hkb_RequirementBookDemand { get; set; }
        public virtual DbSet<hkb_RequirementBookEquipment> hkb_RequirementBookEquipment { get; set; }
        public virtual DbSet<hkb_RequirementBookGuarantee> hkb_RequirementBookGuarantee { get; set; }
        public virtual DbSet<hkb_RequirementBookHouse> hkb_RequirementBookHouse { get; set; }
        public virtual DbSet<hkb_RequirementBookInsurance> hkb_RequirementBookInsurance { get; set; }
        public virtual DbSet<hkb_RequirementBookJob> hkb_RequirementBookJob { get; set; }
        public virtual DbSet<hkb_RequirementBookOtherAsset> hkb_RequirementBookOtherAsset { get; set; }
        public virtual DbSet<hkb_RequirementBookTrace> hkb_RequirementBookTrace { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Entity<hkb_Organization>()
                .HasMany(e => e.hkb_RequirementBook)
                .WithRequired(e => e.hkb_Organization)
                .WillCascadeOnDelete(false);

            modelBuilder.Entity<hkb_Organization>()
                .HasMany(e => e.hkb_OrganizationQualification)
                .WithRequired(e => e.hkb_Organization)
                .WillCascadeOnDelete(false);

            modelBuilder.Entity<hkb_Organization>()
                .HasMany(e => e.hkb_OrganizationDayStatistics)
                .WithRequired(e => e.hkb_Organization)
                .WillCascadeOnDelete(false);

            modelBuilder.Entity<hkb_Organization>()
                .HasMany(e => e.hkb_OrganizationUser)
                .WithRequired(e => e.hkb_Organization)
                .WillCascadeOnDelete(false);

            modelBuilder.Entity<hkb_OrganizationUser>()
                .Property(e => e.CellPhone)
                .IsUnicode(false);

            modelBuilder.Entity<hkb_OrganizationUser>()
                .Property(e => e.Password)
                .IsUnicode(false);

            modelBuilder.Entity<hkb_RequirementBook>()
                .Property(e => e.IDCard)
                .IsUnicode(false);

            modelBuilder.Entity<hkb_RequirementBook>()
                .HasMany(e => e.hkb_RequirementBookCar)
                .WithRequired(e => e.hkb_RequirementBook)
                .WillCascadeOnDelete(false);

            modelBuilder.Entity<hkb_RequirementBook>()
                .HasMany(e => e.hkb_RequirementBookCompany)
                .WithRequired(e => e.hkb_RequirementBook)
                .WillCascadeOnDelete(false);

            modelBuilder.Entity<hkb_RequirementBook>()
                .HasMany(e => e.hkb_RequirementBookCredit)
                .WithRequired(e => e.hkb_RequirementBook)
                .WillCascadeOnDelete(false);

            modelBuilder.Entity<hkb_RequirementBook>()
                .HasMany(e => e.hkb_RequirementBookDemand)
                .WithRequired(e => e.hkb_RequirementBook)
                .WillCascadeOnDelete(false);

            modelBuilder.Entity<hkb_RequirementBook>()
                .HasMany(e => e.hkb_RequirementBookEquipment)
                .WithRequired(e => e.hkb_RequirementBook)
                .WillCascadeOnDelete(false);

            modelBuilder.Entity<hkb_RequirementBook>()
                .HasMany(e => e.hkb_RequirementBookGuarantee)
                .WithRequired(e => e.hkb_RequirementBook)
                .WillCascadeOnDelete(false);

            modelBuilder.Entity<hkb_RequirementBook>()
                .HasOptional(e => e.hkb_RequirementBookTrace)
                .WithRequired(e => e.hkb_RequirementBook);

            modelBuilder.Entity<hkb_RequirementBook>()
                .HasMany(e => e.hkb_RequirementBookHouse)
                .WithRequired(e => e.hkb_RequirementBook)
                .WillCascadeOnDelete(false);

            modelBuilder.Entity<hkb_RequirementBook>()
                .HasMany(e => e.hkb_RequirementBookInsurance)
                .WithRequired(e => e.hkb_RequirementBook)
                .WillCascadeOnDelete(false);

            modelBuilder.Entity<hkb_RequirementBook>()
                .HasMany(e => e.hkb_RequirementBookJob)
                .WithRequired(e => e.hkb_RequirementBook)
                .WillCascadeOnDelete(false);

            modelBuilder.Entity<hkb_RequirementBook>()
                .HasMany(e => e.hkb_RequirementBookOtherAsset)
                .WithRequired(e => e.hkb_RequirementBook)
                .WillCascadeOnDelete(false);
        }
    }
}
